{include file='common/head.html'}

<div class="layui-body">
    {if([$list])}
    <div class="layui-tab layui-tab-brief" lay-filter="tab">
        <ul class="layui-tab-title">
            <li class="layui-this" lay-id="t1">留言列表</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <!-- 搜索 -->
                <form action="{url./admin/Message/index}" method="get" class="layui-form">
                    <div class="layui-form-item nospace">
                        <div class="layui-input-inline">
                            {$pathinfo}
                            {php}$type = get('type');{/php}
                            <select name="type">
                                <option value="">全部字段</option>
                                {foreach $fields(key2,value2,num2)}
                                <option value="[value2->name]" {if($value2->name==$type)}selected="selected"{/if}>[value2->description]</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" value="{$get.keyword}" placeholder="请输入搜索关键字" class="layui-input">
                        </div>
                        <div class="layui-input-inline" style="width: 130px;">
                            {php}$view_status = get('view_status');{/php}
                            <select name="view_status">
                                <option value="">选择审核状态</option>
                                <option value="1" {if(1==$view_status)}selected="selected"{/if}>已审核</option>
                                <option value="2" {if(2==$view_status)}selected="selected"{/if}>未审核</option>
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit onclick="submit();">搜索</button>
                            <a class="layui-btn layui-btn-primary" href="{url./admin/Message/index}">清除搜索</a>
                        </div>
                    </div>
                </form>
                <!-- 列表显示 -->
                <form action="{url./admin/Message/del}" method="post" id="contentForm" name="contentForm" class="layui-form" onkeydown="if(event.keyCode==13) return false;">
                    <input type="hidden" name="formcheck" value="{$formcheck}" > 
                    <table class="layui-table">
                        <thead>
                            <tr>
                                <th width="10"><input type="checkbox" class="checkbox" lay-ignore id="checkall" title="全选"></th>
                                <th width="30">序号</th>
                                
                                {foreach $fields(key2,value2,num2)}
                                {if($value2->is_list)}
                                <th>[value2->description]</th>
                                {/if}
                                {/foreach}
                                <th width="150">时间</th>
                                <th width="60">审核</th>
                                <th width="150">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            
                            {foreach $messages(key,value,num)}
                            <tr>
                                <td><input type="checkbox" class="checkbox checkitem" lay-ignore name="list[]" value="[value->id]" id="checka"></td>
                                <td>{php}echo $numdesc = [$pagerows]-$num+1;{/php}</td>
                                
                                {foreach $fields(key2,value2,num2)}
                                {php} $field=$value2->name;{/php}

                                {if($value2->is_list)}
                                {if(preg_match('/(\.(jpg|gif|png|bmp|jpeg|ico|webp))$/i', $value->$field) || strpos($value->$field,'qlogo'))}
                                <td><a href='[value->$field]' target='_blank'><img src='[value->$field]' width='30' height='30' style='float: unset;cursor: pointer;' /></a></td>
                                {/if}

                                {if(preg_match('/(\.(zip|gz|rar|iso|doc|xsl|ppt|wps|docx|xslx|pdf))$/i', $value->$field))}
                                {php}$arr=explode("/", $value->$field);$last=$arr[count($arr)-1];{/php}
                                <td><a href='[value->$field]' target='_blank'>{php}echo $last;{/php}</a></td>
                                {/if}

                                {if(!preg_match('/(\.(jpg|gif|png|bmp|jpeg|ico|webp|zip|gz|rar|iso|doc|xsl|ppt|wps|docx|xslx|pdf))$/i', $value->$field) && !strpos($value->$field,'qlogo'))}
                                <td>[value->$field]</td>
                                {/if}
                                {/if}
                                
                                {/foreach}
                                <td>[value->create_time]</td>
                                <td>
                                    {if($value->view_status==1)}
                                    <a href="{url./admin/'.C.'/mod/id/'.$value->id.'/field/view_status/value/2}"><i class='fa fa-toggle-on' style="vertical-align:middle"></i></a>
                                    {else}
                                    <a href="{url./admin/'.C.'/mod/id/'.$value->id.'/field/view_status/value/1}"><i class='fa fa-toggle-off' style="vertical-align:middle"></i></a>
                                    {/if}
                                </td>
                                <td>
                                    {if(check_level('mod'))}
                                    {fun=get_btn_mod($value->id,'id','详情')}
                                    {/if}
                                    {fun=get_btn_del($value->id)}
                                </td>
                            </tr>
                            {/foreach}
                        </tbody>
                    </table>
                    
                    <div class="layui-btn-group">
                        {if([$messages])}
                        <a href="{url./admin/Message/index/export/1}" class="layui-btn layui-btn-sm">导出全部记录</a>&nbsp;
                        {/if}
                        <button type="submit" name="submit" onclick="return setDelAction();" class="layui-btn layui-btn-sm layui-btn-danger">批量删除</button>
                        {if(session('ucode')==10001 && [$messages])}
                        <a href="{url./admin/Message/clear}" onclick='return confirm("您确定要全部清空么？")' class="layui-btn layui-btn-sm layui-btn-danger">清空全部记录</a>
                        {/if}
                    </div>
                    <div class="page">{$pagebar}</div>
                </form>
            </div>
        </div>
    </div>
    <script>
        function setDelAction(){
            document.contentForm.action = "{url./admin/Message/del}"; 
            return confirm("您确定要删除选中的内容么？");
        }
    </script>



    {/if}
    {if([$mod])}
    <div class="layui-tab layui-tab-brief" lay-filter="tab">
        <ul class="layui-tab-title">
            <li class="layui-this">留言详情</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

   
                <form action="{url./admin/Message/mod/id/'.[$get.id].'}{$backurl}" method="post" class="layui-form">
                    <input type="hidden" name="formcheck" value="{$formcheck}">
                        <table class="layui-table table-two">
                                        <tbody>
                                            {foreach $fields(key2,value2,num2)}
                                                <tr>
                                                    <th>[value2->description]</th>
                                                    {php} $field=$value2->name {/php}
                                                    
                                                    <td>
                                                        {foreach $messages(key,value,num)}
                                                        {if($value2->name == $key)}

                                                        {if(preg_match('/(\.(jpg|gif|png|bmp|jpeg|ico|webp))$/i', $value))}
                                                        <a href='[value]' target='_blank'><img src='[value]' width='60' height='60' style='float: unset;cursor: pointer;' /></a>
                                                        {/if}
                                                        {if(preg_match('/(\.(zip|gz|rar|iso|doc|xsl|ppt|wps|docx|xslx|pdf))$/i', $value))}
                                                        {php}$arr=explode("/", $value);$last=$arr[count($arr)-1];{/php}
                                                        <a href='[value]' target='_blank'>{php}echo $last;{/php}</a>
                                                        {/if}
                                                        {if(!preg_match('/(\.(jpg|gif|png|bmp|jpeg|ico|webp|zip|gz|rar|iso|doc|xsl|ppt|wps|docx|xslx|pdf))$/i', $value))}
                                                        [value]
                                                        {/if}

                                                        {/if}
                                                        {/foreach}
                                                    </td>
                                                </tr>
                                            {/foreach}

                                            <tr>
                                                <th>时间</th>
                                                <td>{$messages->create_time}</td>
                                            </tr>
                                            <tr>
                                                <th>访客信息</th>
                                                <td>
                                                    IP:<a href="http://ip.taobao.com/ipSearch.html?ipAddr={fun=long2ip([$messages->user_ip])}" target="_blank" title="点击查看归属地">{fun=long2ip([$messages->user_ip])}</a>；
                                                    浏览器:{$messages->user_bs}；
                                                    操作系统:{$messages->user_os}
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>回复内容</th>
                                                <td><textarea name="recontent" placeholder="请输入回复内容" class="layui-textarea">{$message->recontent}</textarea></td>
                                            </tr>
                                            <tr>
                                                <th>前台状态</th>
                                                <td><input type="radio" name="status" value="1" title="显示" {if([$message->status]==1)}checked="checked"{/if}>
                                                    <input type="radio" name="status" value="0" title="隐藏" {if([$message->status]==0)}checked="checked"{/if}></td>
                                            </tr>
                                        </tbody></table>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                            <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
                            {fun=get_btn_back()}
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    {/if}
</div>
{include file='common/foot.html'}